<?php
require_once('../includes/SmartyManager.class.php');
require_once('../includes/functions.inc.php');
require_once('../includes/exceptions/AppExceptions.class.php');
require_once('../includes/SpecialMainStateAccount.class.php');
require_once('../includes/MainFileStateAccountant.class.php');

$smarty = SmartyManager::getSmarty();
//try{

if(isset($_GET['filename'])){
	$smarty->assign('filename', $_GET['filename']);

	defined("DEBUG")?$pre=getMicroTime():null;

	$account = new SpecialMainStateAccountant($_GET['filename']);
	$account->execute();
	$smarty->assign( array(
				'certificationNumber'	=> $account->getCertificationNumber(),
				'sampleBatch'	=> $account->getSampleBatch(),
				'materialCode' 	=> 	$account->getMaterialCode(),
				'sequenceNumber' 		=> 	$account->getSequenceNumber(),
				'manufactory' 		=> 	$account->getManufactory(),
				'authenticationMark' 		=> 	$account->getAuthenticationMark(),
				'steelNumber' 		=> 	$account->getSteelNumber(),
				'size1' 		=> 	$account->getSize1(),
				'size2' 		=> 	$account->getSize2(),
				'size3' 		=> 	$account->getSize3(),
				'main3Count'	=>	$account->getMain3Count(),
				'main3SumCount'	=>	$account->getMain3SumCount(),
				'main3AllocatedCount'	=> $account->getMain3AllocatedCount(),
				'mainSumCount'	=>	$account->getMainSumCount(),
				'mainAllocatedCount'	=> $account->getMainAllocatedCount(),
				'mainCount'		=> $account->getMainCount(),
				'mainCertificationCount'	=> $account->getMainCertificationCount(),
				'unitWeight'		=>	$account->getUnitWeight(),
				'orderNumber'		=>	$account->getOrderNumber(),
				'orderSubitemNumber'		=>	$account->getOrderSubitemNumber(),
				'unitPrice'		=>	$account->getUnitPrice(),
				'purchaseNumber'	=>  $account->getPurchaseNumber(),
				'remark'	=>  $account->getRemark(),
				'certificationCodification'	=> $account->getCertificationCodification(),
				'materialNumber'	=> $account->getMaterialNumber(),
				'shipmentDate'	=> $account->getShipmentDate(),
				'month'	=> $account->getMonth(),
				'vehicleNumber'	=> $account->getVehicleNumber(),
				'consignee'	=> $account->getConsignee()
		));
	if(defined("DEBUG")){
		$inteval = getMicroTime()-$pre;
		echo "a speacial file state Time:".$inteval.'<br />';
	}
	$smarty->display('mainStat.html');

}else{

	defined("DEBUG")?$pre=getMicroTime():null;

	$account = new MainFileStateAccountant(true);
	$account->execute();

	if(defined("DEBUG")){
		$inteval = getMicroTime()-$pre;
		echo "get all files'state Time:".$inteval.'<br />';
	}
	$smarty->assign('filename', $account->getFilename());
	$smarty->assign('uploadTime', $account->getUploadTime());
	$smarty->assign('allCount', $account->getAllCount());
	$smarty->assign('finishedCount', $account->getFinishedCount());
	$smarty->display('mainFileStats.html');
}
//
//}catch(Exception $e){
//	$smarty->assign('errTitle', '出现错误');
//	$smarty->assign('errMsg', '数据库查询和运算时出现错误');
//	$smarty->display('error.html');
//}
?>